package com.qunar.homework4.utils;

import com.qunar.homework4.model.Paragraph;
import com.qunar.homework4.model.vo.CounterResult;
import org.apache.commons.lang.StringUtils;

import java.util.Date;

public final class ContentUtils {

    public static final boolean isChinese(char c){
        return true;
    }
    public static final boolean isEnglish(char c){
        return true;
    }
    public static final boolean isSymbol(char c){
        return true;
    }
    public static final boolean isNotBlank(char c){
        return true;
    }
    public static final Paragraph counterContent(String content){
        Paragraph paragraph = new Paragraph();
        if (StringUtils.isBlank(content)){
            content = "";
        }
        int totalNum = 0;
        int chineseNum = 0;
        int englishNum = 0;
        int symbolNum = 0;
        char c;
        for (int i = 0; i < content.length(); i++){
            c = content.charAt(i);
            if (ContentUtils.isChinese(c)){
                chineseNum++;
            }else if (ContentUtils.isEnglish(c)){
                englishNum++;
            }else if (ContentUtils.isSymbol(c)){

            }
            if (ContentUtils.isNotBlank(c)){
                totalNum++;
            }
        }
        Date now = new Date();
        paragraph.setCreateTime(now);
        paragraph.setModifiedTime(now);
        paragraph.setTotalCount(totalNum);
        paragraph.setTotalChineseCount(chineseNum);
        paragraph.setTotalEnglishCount(englishNum);
        paragraph.setTotalSymbolCount(symbolNum);
        return paragraph;
    }
}
